package com.shopping.serviceImpl;

import com.shopping.dao.ProductDao;
import com.shopping.pojo.Product;
import com.shopping.pojo.vo.ProductInfo;
import com.shopping.pojo.vo.ProductSpecInfo;
import com.shopping.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao productDao;

    @Override
    public List<ProductSpecInfo> selectProductByQuery(String productName, String businessName, String cateName, int start, int limit) {
        return productDao.selectProductByQuery(productName, businessName, cateName, start, limit);
    }

    @Override
    public int getProductNum(String productName, String businessName, String cateName) {
        return productDao.getProductNum(productName, businessName, cateName);
    }

    @Override
    public boolean updateProductStatusCompulsory(Integer productId) {
        return productDao.updateProductStatusCompulsory(productId) > 0;
    }

    @Override
    public boolean updateProductStatusAllow(Integer productId) {
        return productDao.updateProductStatusAllow(productId) > 0;
    }

    @Override
    public int getBusinessProductsNum(Integer id) {
        return productDao.getBusinessProductsNum(id);
    }

    @Override
    public List<Product> selectBusinessProductByProductName(String businessId, String productName) {
        return productDao.selectBusinessProductByProductName(businessId, productName);
    }

    @Override
    public boolean updateProductPutOnSale(Integer productId) {
        return productDao.updateProductPutOnSale(productId) > 0;
    }

    @Override
    public boolean updateProductPullOff(Integer productId) {
        return productDao.updateProductPullOff(productId) > 0;
    }

    @Override
    public boolean deleteProduct(Integer productId) {
        return productDao.deleteProduct(productId) > 0;
    }

    @Override
    public boolean updateProductDelete(Integer productId) {
        return productDao.updateProductDelete(productId) > 0;
    }

    @Override
    public boolean insertProduct(Product product) {
        return productDao.insertProduct(product) > 0;
    }

    @Override
    public boolean updateProduct(Product product) {
        return productDao.updateProduct(product) > 0;
    }

    @Override
    public List<ProductInfo> selectMainRecommendProduct() {
        return productDao.selectMainRecommendProduct();
    }

    @Override
    public List<ProductInfo> selectMainNewProduct() {
        return productDao.selectMainNewProduct();
    }

    @Override
    public List<ProductInfo> selectProductByProductName(String productName) {
        return productDao.selectProductByProductName(productName);
    }

    @Override
    public ProductInfo selectProductInfoByProductId(Integer productId) {
        return productDao.selectProductInfoByProductId(productId);
    }

    @Override
    public List<ProductInfo> selectProductInfoByBusinessIdAndProductName(String businessId, String productName) {
        return productDao.selectProductInfoByBusinessIdAndProductName(businessId, productName);
    }

    @Override
    public List<ProductInfo> selectProductByCateName(String cateName) {
        return productDao.selectProductByCateName(cateName);
    }

    @Override
    public boolean checkProductByCateId(Integer categoryId) {
        return productDao.checkProductByCateId(categoryId)>0;
    }

}
